//
// Decompiled by Jadx - 358ms
//
package k;

import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;

public final class d extends b {
    public final HashMap<String, CharSequence> a = new HashMap<>();
    public final int c;
    public final int d;

    public d(CharSequence[]... charSequenceArr) {
        int i = Integer.MAX_VALUE;
        int i2 = 0;
        for (CharSequence[] charSequenceArr2 : charSequenceArr) {
            this.a.put(charSequenceArr2[0].toString(), charSequenceArr2[1]);
            int length = charSequenceArr2[0].length();
            i = length < i ? length : i;
            if (length > i2) {
                i2 = length;
            }
        }
        this.c = i;
        this.d = i2;
    }

    public final int b(String str, int i, StringWriter stringWriter) throws IOException {
        int i2 = this.d;
        if (i + i2 > str.length()) {
            i2 = str.length() - i;
        }
        while (i2 >= this.c) {
            CharSequence charSequence = this.a.get(str.subSequence(i, i + i2).toString());
            if (charSequence != null) {
                stringWriter.write(charSequence.toString());
                return i2;
            }
            i2--;
        }
        return 0;
    }
}
